import logging
import traceback

from wcferry import WxMsg, Wcf

from modules.module_base import ModuleBase
from utils.gpt_util import GPTUtil


class ResponseSingleModule(ModuleBase):

    def __init__(self):
        super().__init__()
        self.log = logging.getLogger(__name__)
        self.open_ai = GPTUtil()
        self.white_list = [""]

    def run(self, msg: WxMsg, wcf: Wcf):
        # 消息类型为1，代表普通的文本消息
        # not msg.from_group 代表非群聊消息，即个人消息
        if msg.type == 1 and not msg.from_group() and msg.sender != wcf.get_self_wxid():
            self.log.info(f"收到个人消息：{msg.content}")
            # try:
            #     if "加群" in msg.content:
            #         res = wcf.invite_chatroom_members("43082420810@chatroom", msg.sender)
            #         self.log.info(f"已邀请{msg.sender}添加到粉丝群，结果：{res}")
            # except Exception as e:
            #     self.log.error(f"发送失败：{traceback.format_exc()}")

